package com.zerox.interceptor;

import com.zerox.pojo.SysUser;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class SysIntercetor extends HandlerInterceptorAdapter {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        //是否登录
        SysUser sysUser = (SysUser) request.getSession().getAttribute("loginUser");
        if (sysUser == null){
            response.setContentType("text/html;charset=utf-8");
            response.getWriter().print("请先登录");
            return false;
        }
         return true;
    }
}
